package top.huntwolf.admin.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import top.huntwolf.admin.common.enums.OrderStatus;
import top.huntwolf.admin.pojo.orderEntity.Order;
import top.huntwolf.admin.pojo.orderEntity.OrderBook;
import top.huntwolf.admin.pojo.PurchaseVo;
import top.huntwolf.admin.pojo.Trade;

import java.util.List;

@Mapper
@Repository
public interface OrderDao {

    /*查询一个*/
    Order selectOrderById(String orderId);

    /*查询全部*/
    List<Order> selectAll();

    /*查询购买订单里全部书籍*/
    Order selectBuyBooksInOrder(String orderId);

    /*查询出售订单里全部书籍*/
    Order selectSaleBooksInOrder(String orderId);

    /*根据open_id查询所有购买订单*/
    List<Order> selectBuyOrderByUser(String openId,String type);

    /*根据open_id查询所有卖书订单*/
    List<Order> selectSaleOrderByUser(String openId,String type);

    /*查询所有卖书订单*/
    List<Order> selectSaleOrder(String openId);

    /*增加一个*/
    int insert(Order order);

    /*增加一个卖书订单*/
    int insertSale(Order order);

    /*保存订单关联书本信息*/
    int saveOrderBook(List<OrderBook> books);

    /*删除一个*/
    int delete(@Param("order_id") String orderId);

    /*更新一个*/
    int update(Order order);

    int updateStatus(String orderId, OrderStatus orderStatus);

    /*修改一个卖书信息*/
    int updateOrderBook(OrderBook orderBook);

    /*获取上个月的所有订单*/
    List<Order> selectBuyBooksAllOrderNumLastMonth();

    /*获取书本的交易数*/
    Trade selectBuyBookTransaction(String isbn);

    /*获取最近订单数*/
    List<PurchaseVo> selectRecentBuyBook();


    List<Order> selectByAgentId(String openId);
}
